import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { enterpriseInfoVO, enterpriseInfoForm, enterpriseInfoQuery } from '@/api/enterprise/enterprise-info/types';
import { UserInfoVO } from '@/api/access/user/user-info/types';

/**
 * 查询企业信息列表
 * @param query
 * @returns {*}
 */

export const listenterpriseInfo = (query?: enterpriseInfoQuery): AxiosPromise<enterpriseInfoVO[]> => {
  return request({
    url: '/enterprise/enterprise-info/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询企业信息详细
 * @param enterpriseInfoId
 */
export const getenterpriseInfo = (enterpriseInfoId: string | number): AxiosPromise<enterpriseInfoVO> => {
  return request({
    url: '/enterprise/enterprise-info/' + enterpriseInfoId,
    method: 'get'
  });
};

/**
 * 新增企业信息
 * @param data
 */
export const addenterpriseInfo = (data: enterpriseInfoForm) => {
  return request({
    url: '/enterprise/enterprise-info',
    method: 'post',
    data: data
  });
};

/**
 * 修改企业信息
 * @param data
 */
export const updateenterpriseInfo = (data: enterpriseInfoForm) => {
  return request({
    url: '/enterprise/enterprise-info',
    method: 'put',
    data: data
  });
};

/**
 * 删除企业信息
 * @param enterpriseInfoId
 */
export const delenterpriseInfo = (enterpriseInfoId: string | number | Array<string | number>) => {
  return request({
    url: '/enterprise/enterprise-info/' + enterpriseInfoId,
    method: 'delete'
  });
};

/**
 * 获取梯控授权用户
 * @param elevatorId 梯控ID
 * @param query 查询条件
 */
export const grantInfo = (elevatorId: string | number, query?: UserInfoVO) => {
  return request({
    url: '/user/groupElevator/grantInfo/' + elevatorId,
    method: 'get',
    params: query
  });
};
